/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2019-02-13 Time: 23:07
 */
import {RetrieveMaterial} from "./Actions"
import {FetchStatus} from "../../../../configuration/RequestConfiguration"


/**
 * 获取耗材列表
 * @param state
 * @param action
 * @returns {{fetchStatus: *}}
 */
export const onRetrieveMaterial = (state = {}, action) => {
    switch (action.type) {
        case RetrieveMaterial: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
}
